import { RequestModel} from 'models/requestModel.js'
let requestModel = new RequestModel()
App({
  accessTokenDic: null,
  userInfodic: null,
  systemTimeGap: null,
  accessUnionid: null,
  /**当小程序初始化完成时，会触发 onLaunch（全局只触发一次）*/
  onLaunch: function () {
    this.accessTokenDic = wx.getStorageSync('fwServerKey')
    this.userInfodic = wx.getStorageSync('haiwaigouUserKey')
    this.accessUnionid = wx.getStorageSync('haiwaigouUnionidKey')
  },
  /**当小程序启动，或从后台进入前台显示，会触发 onShow*/
  onShow: function (options) {
    requestModel.getsystemTime({
      urlType:'SNSTC',
      url:'sns/timestamp'
    }).then(res=>{
      let stime = res;
      let timestamp = (new Date()).valueOf()
      timestamp = parseInt(timestamp / 1000)
      this.systemTimeGap = timestamp - parseInt(stime / 1000);
    })
    // console.log(this.accessTokenDic)
  },
  /** 当小程序从前台进入后台，会触发 onHide*/
  onHide: function () {

  },
  /**当小程序发生脚本错误，或者 api 调用失败时，会触发 onError 并带上错误信息*/
  onError: function (msg) {

  }
  // getrequestTime: function () {
  //   var that = this
  //   req.reqGET('SNSTC', 'sns/timestamp', function (res) {
  //     var stime = res;
  //     var timestamp = (new Date()).valueOf();
  //     timestamp = parseInt(timestamp / 1000);
  //     that.systemTimeGap = timestamp - parseInt(stime / 1000);
  //   })
  // }
})
